<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<ui:composition xmlns="http://www.w3.org/1999/xhtml"
	xmlns:ui="http://java.sun.com/jsf/facelets"
	xmlns:f="http://java.sun.com/jsf/core"
	xmlns:h="http://java.sun.com/jsf/html"
	xmlns:a4j="http://richfaces.org/a4j"
	xmlns:rich="http://richfaces.org/rich"
	xmlns:c="http://java.sun.com/jstl/core"	
	xmlns:p="http://primefaces.prime.com.tr/ui">

	<h:form id="idSetorMBForm">
		<p:panel>
			<p:messages globalOnly="true" rendered="true"/>
			<f:facet name="header">
				<h:outputText value="#{msg.setor}" />
			</f:facet>
	
			<fieldset id="legend_area"><legend id="legend"><h:outputLabel
				value="#{msg.setorDados}" /></legend> 
				<h:panelGrid columns="2">
					<h:panelGroup>
						<br/>
						<h:outputLabel value="#{msg.nome}" for="idNomeSetor" />
						<span class="req"> *</span>
					</h:panelGroup>
					<h:panelGroup>
						<rich:message for="idNomeSetor" styleClass="mensagem_erro_campo" /><br/>
						<h:inputHidden value="#{setorMB.setor.id}"/>
						<h:inputText id="idNomeSetor"
							value="#{setorMB.setor.nome}" size="25" maxlength="25"
							onkeyup="javascript:toUpperCase(this);" required="true"
							requiredMessage="#{msg.campoObrigatorio}">
							<rich:ajaxValidator event="onblur" />
						</h:inputText>
					</h:panelGroup>
	
					<h:panelGroup>
						<br/>
						<h:outputLabel value="#{msg.instituicao}" for="idInstituicao" /><span class="req"> *</span>
					</h:panelGroup>
					<h:panelGroup>
						<rich:message for="idInstituicaoSetor" styleClass="mensagem_erro_campo"/>
						<rich:comboBox id="idInstituicaoSetor" defaultLabel="#{msg.escolhaOpcao}"
							width="250" enableManualInput="false"
							value="#{setorMB.setor.instituicao.nome}" required="true"
							requiredMessage="#{msg.campoObrigatorio}">
							<f:selectItems value="#{instituicaoMB.instituicaoOpts}" />
							<rich:ajaxValidator event="onblur" />
						</rich:comboBox>
					</h:panelGroup>
				</h:panelGrid>
			</fieldset>
			<br />
	
			<h:panelGrid columns="2" width="100%" style="text-align:center;">
				<h:panelGroup>
					<a4j:commandButton value="#{msg.botaoSalvar}"
						action="#{setorMB.save}" reRender="idSetorMBForm, setorList"
						style="text-align:center;" />
					<rich:spacer width="15px" />
					<a4j:commandButton value="#{msg.botaoAtualizar}"
						action="#{setorMB.atualiza}" style="text-align:center;" reRender="idSetorMBForm, setorList, mensagens"/>
					<rich:spacer width="15px"/>
					<a4j:commandButton value="#{msg.botaoLimpar}"
						action="#{setorMB.limpar}" reRender="idSetorMBForm, setorList, mensagens"
						style="text-align:center;" />
				</h:panelGroup>
			</h:panelGrid>
		</p:panel>
	
	</h:form>
	<br />
	<h:form>
		<p:panel>
			<a4j:commandButton reRender="idSetorMBForm" value="#{msg.alterar}" action="#{setorMB.listaToFormSetor}"/>
			<h:commandButton onclick="return confirm('Deseja excluir o registro?')" value="#{msg.excluir}" action="#{setorMB.remove}" reRender="setorList"/>
			<p:dataTable id="setorList" var="setor" value="#{setorMB.setorList}" paginator="true" rows="6" 
				selection="#{setorMB.setorSelectedList}" selectionMode="multiple">
				
				<p:column filterBy="#{setor.nome}" sortBy="#{setor.nome}" width="200">
					<f:facet name="header">
						<h:outputText value="#{msg.nome}" />
					</f:facet>
					<h:outputText value="#{setor.nome}" />
				</p:column>
			</p:dataTable>
			<h:outputText value="#{msg.exportarTodosDados}" style="font-weight:bold"/>:
			<h:commandLink>
				<p:graphicImage value="/images/excel.png" style="border:0;"/>
				<p:dataExporter type="xls" target="setorList" fileName="#{msg.setor}" />
			</h:commandLink>
			<h:commandLink>
				<p:graphicImage value="/images/pdf.png" style="border:0;"/>
				<p:dataExporter type="pdf" target="setorList" fileName="#{msg.setor}"/>
			</h:commandLink><rich:spacer width="10px"/>
	
			<h:outputText value="#{msg.exportarDadosPagina}" style="font-weight:bold"/>:
			<h:commandLink>
				<p:graphicImage value="/images/excel.png" style="border:0;"/>
				<p:dataExporter type="xls" target="setorList" fileName="#{msg.setor}" />
			</h:commandLink>
			<h:commandLink>
				<p:graphicImage value="/images/pdf.png" style="border:0;"/>
				<p:dataExporter type="pdf" target="setorList" fileName="#{msg.setor}"/>
			</h:commandLink>
		</p:panel>
	</h:form>
</ui:composition>